package com.wcl.demo.ui.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.wcl.demo.R;
import com.wcl.demo.ui.activity.ChosePhotoActivity;
import com.wcl.demo.ui.activity.TakePhotoActivity;

/**
 * Created by dllo on 15/11/25.
 */
public class NoteDialogFragment extends DialogFragment implements View.OnClickListener {
    private TextView dialog_take_photo_Btn,dialog_chose_picture_Btn,dialog_bac_Btn;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view=inflater.inflate(R.layout.fragment_dialog,container);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        dialog_take_photo_Btn= (TextView) view.findViewById(R.id.dialog_take_photo_Btn);
        dialog_chose_picture_Btn= (TextView) view.findViewById(R.id.dialog_chose_picture_Btn);
        dialog_bac_Btn= (TextView) view.findViewById(R.id.dialog_bac_Btn);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        dialog_take_photo_Btn.setOnClickListener(this);
        dialog_chose_picture_Btn.setOnClickListener(this);
        dialog_bac_Btn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.dialog_take_photo_Btn:
                Intent intent =new Intent(getActivity(), TakePhotoActivity.class);
                getActivity().startActivity(intent);
                getActivity().finish();
                break;
            case R.id.dialog_chose_picture_Btn:
                Intent intent_chosePhoto =new Intent(getActivity(), ChosePhotoActivity.class);
                intent_chosePhoto.putExtra("chosePicture_key","1");//调用选图的方法"1"
                getActivity().startActivity(intent_chosePhoto);
                getActivity().finish();
                break;
            case R.id.dialog_bac_Btn:
                DialogFragment df = (DialogFragment) getActivity().getSupportFragmentManager().findFragmentByTag("dialogfragment");
                df.dismiss();
                break;
        }
//        Toast.makeText(getActivity(),"gogogogoggogo",0).show();
    }
}
